/* <![CDATA[ */

function exitBumpbox(){
	var bg=$('bg');
	var el=$('grow');
	var eff2 = new Fx.Morph('grow', { duration: 500, wait:'link', onComplete:function(){
		el.dispose();
	}
	});
	$('bg').dispose();
	$('grow').getChildren().dispose();
	eff2.start({
	  opacity: [1, 0]
	 });
}


function bumpbox(){
$$('.bumpbox').addEvent('click',function(e){
	var fistBG=$('bg');
	if(fistBG!=null) fistBG.dispose();
	e = new Event(e).stop();

	if($('grow')!= null){
		$('grow').dispose();
	}

	var content =rootURL+'/'+ this.get('href');
	maxw = 0;
	maxh = 0;
	var title = "";
	if(this.get('rel')!= null){
		var tmp = this.get('rel').split(",");	
		maxw = tmp[0];
		maxh = tmp[1];
		if(tmp[2]!=null) title=tmp[2];
		if(tmp[3]!=null) content=rootURL+'/'+tmp[3];
	}
	
	if(this.get('title') != null){
		title = this.get('title');
	}
	
	if(maxw == 0){	maxw = 640;	}
	if(maxh == 0){	maxh = 480;	}

	w = window.getSize().x.toInt();
	h = window.getSize().y.toInt();
	s = window.getScrollTop();
	var middleH = (w) / 2;
	var middleV = (h) / 2;
	var endleft = (w-maxw) / 2;
	var endtop = ((h - maxh) / 2) + s;
	

	var el = new Element('div', {
		 'styles':{
			 width: maxw+'px',
			 height: maxh+'px',
			 position:'absolute',
			 border:'3px solid #303132',
			 borderTop:'3px solid #303132',
			 background:'#222',
			 left:middleH +"px",
			 top:middleV + "px",
			 display:'block',
			 'z-index':130000,
			 left: endleft+'px',
			 top: endtop+'px'
		},
		'id': 'grow'
	});


	bg = new Element('div',{
	'styles':{
		background:'#000',
		width:'100%',
		height:'100%',
		opacity:'0.1',
//		cursor:'pointer',
		position:'absolute',
		top: window.getScrollTop(),
		left: 0
	},
	'id':'bg'
	});
	
	bg.inject(document.body);
	el.injectInside(document.body);
	
	window.addEvent('scroll',function(){
		$(bg).setStyle('top',window.getScrollTop());
	});

	
	
	var eff3 = new Fx.Morph('grow', { duration: 500, wait:'link',onComplete:function(){
		el.dispose();
  }
							});
	
	
	var eff2 = new Fx.Morph('grow', { duration: 500, wait:'link', onComplete:function(){
		
		el.dispose();
	}
	 });
	
	
	bg.addEvent('click',function(e){
//			e = new Event(e).stop();
//			bg.dispose();
//			$(el).getChildren().dispose();
//			eff2.start({
//			  opacity: [1, 0]
//			 });
		});
	
	/*	$(el).addEvent('click',function(e){
			e = new Event(e).stop();
			bg.dispose();
			this.getChildren().dispose();
			eff2.start({
			  'width':[maxw,1],
			  'height':[maxh,1],
			  'left': [endleft,middleH],
			  'top':  [endtop, middleV+s]
			 })
		})
	*/	

	
	var eff = new Fx.Morph('grow', {duration: 500,onComplete:function(){
				
		if(content.indexOf("http") != -1  && content.indexOf('.flv') == -1 && content.indexOf(".pdf") == -1 && content.indexOf(".swf") == -1 
		    && content.indexOf(".jpg") == -1 && content.indexOf(".gif") == -1 && content.indexOf(".png") == -1){
			
				var p = new Element('div');
				p.setStyle('display','block');
				p.setStyle('overflow','hidden');
				p.setStyle('padding','2px');
				p.setStyle('height',maxh-5);
				p.setStyle('width',maxw-5);
				
				p.inject(el);
				
				var x = new Element('div',{'id': 'logBox','style':'margin:0px;padding: 0px;'});
				x.setStyle('overflow','hidden');
				x.set('border','0');
				x.setStyle('width',maxw-5);
				x.setStyle('height',maxh-35);
				x.setStyle('border','1px solid silver');
				x.setStyle('background', 'white url(../images/loading2.gif) no-repeat center');
				//x.inject(p);
				p.grab(x,'top');
				var myrequest=new Request.HTML({
					url: content,
					method: 'get',
					update: x,
					onSuccess: function(responseText, responseXML) { 
					    x.setStyle('background', 'white');
					}
				});
				myrequest.send();
				//close bt
				var closeBt=new Element('div',{'style':'width: 32px;height: 32px;margin-top: -30px;cursor: pointer;','title':'Đóng'});
				closeBt.setStyle('margin-left',maxw-35);
				closeBt.setStyle('background-image','url(../js/1267347139_close.png)');
				el.grab(closeBt,'bottom');
				closeBt.addEvent('click',function(e){
					e = new Event(e).stop();
					bg.dispose();
					$(el).getChildren().dispose();
					eff2.start({
					  opacity: [1, 0]
					 });
				});
				
				//up and down button
				var bienX=0;
				var bienY=0;
				var beginY=x.getPosition()['y'];
				var saveY=x.getPosition()['y'];
				var myScrollFx = new Fx.Scroll(x, {duration: 1000,
					onStart: function(){downBt.removeEvent('click',down);upbt.removeEvent('click',up);saveY=x.getPosition()['y'];},
					onComplete: function(){upbt.addEvent('click',up);
						temp=x.getPosition()['y'];
						if(saveY==temp && temp<beginY){downBt.removeEvent('click',down);bienY=bienY-350;}else {downBt.addEvent('click',down);}
					}
					});
				var up=function(){
					bienY-=350;
					if(bienY<=0) bienY=0;
					myScrollFx.start(bienX,bienY);
				};
				var down=function(){
					bienY=bienY+350;
					myScrollFx.start(bienX,bienY);
					
				};
				
				//bt down
				var downBt=new Element('div',{'style':'width: 48px;height: 48px;cursor: pointer','title':'Đi xuống'});
				downBt.setStyles({
					'background-image': 'url(../js/1267351244_down.png)',
					'margin-top':'-100px',
					'margin-left': maxw-48
				});
				downBt.set('opacity',0.5);
				downBt.addEvents({
					mouseover: function(){
					this.set('opacity',1);	
					},
					mouseout: function(){
						this.set('opacity',0.5);	
					},
					click: down
				});
				el.grab(downBt,'bottom');
				//bt up
				var upbt=new Element('div',{'style':'width: 48px;height: 48px;cursor: pointer','title':'Đi lên'});
				upbt.setStyles({
					'background-image': 'url(../js/1267351251_up.png)',
					'margin-top':'-90px',
					'margin-left': maxw-48
				});
				upbt.set('opacity',0.5);
				upbt.addEvents({
					mouseover: function(){
					this.set('opacity',1);	
					},
					mouseout: function(){
						this.set('opacity',0.5);	
					},
					click: up
				});
				el.grab(upbt,'bottom');
				
				//len top
				myScrollFx.start(0,0);
		}
		
		
		if(title != ""){
			var t = new Element('div',{
			'styles':{
				'height':'25px',
				'width': maxw-50,
//				'background':'#000',
				'padding-top':'5px',
				'padding-left':'10px',
				'font-weight':'bold',
//				'position':'absolute',
//				'bottom':'-50px',
//				'left':'-10px',
				'color':'#eee',
				'margin-top': '65px'
//				'border-bottom':'10px solid #303132',
//				'border-right':'10px solid #303132',
//				'border-left':'10px solid #303132'
			}
		});
			t.set('html',title);
			t.inject(el);
		}
		
	}});
	
	eff.start({
		  opacity: [0, 1]
		 });
 	});
};

/* ]]> */